# 导包
from bs4 import BeautifulSoup

# 待解析数据：后台开户返回的response对象（字典类型数据，但是里面有html标签）
response = {}
# html = """红色字体内容"""
html = response.get("description").get("form")
# 实例化
bs = BeautifulSoup(markup=html, features="html.parser")
# 调用方法
# 1.获取url
url = bs.form.get("action")
# 2.获取name属性值和value属性值
data = bs.find_all("input")
# data = [<input name='Version' type='hidden' value='10'/>,<input name='CmdId' type='hidden' value='UserRegister'/>,<input name='MerCustId' type='hidden' value='6000060007313892'/>]
# 直接组装成：{"Version":"10","CmdId":"UserRegister"}
# 定义空字典
data_dict = {}
for i in data:
    # print(i)  # i = <input name='Version' type='hidden' value='10'/>
    key = i.get("name")  # 'Version'
    value = i.get("value")  # '10'
    data_dict[key] = value  # 字典第一次添加元素 {"Version":"10"}
